import time

from selenium import webdriver

from Lib.zcm.common.ui.Selector import Selector
from .select import Select


def test_select_antd3x():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://3x.ant.design/components/select-cn/")
    selectors = [
        {'selector': '(//section[@id="components-select-demo-basic"]//div[contains(@class,"ant-select ")])[1]',
         'value': ['yiminghe']},
        # 带搜索框
        {'selector': '(//section[@id="components-select-demo-search"]//div[contains(@class,"ant-select ")])[1]',
         'value': ['Tom']},
        # 多选
        {'selector': '(//section[@id="components-select-demo-multiple"]//div[contains(@class,"ant-select ")])[1]',
         'value': ['c12', 'e14', 'f15', 'n23']},
        # 回填
        {'selector': '(//section[@id="components-select-demo-option-label-prop"]//div[contains(@class,"ant-select-selection") and @role="combobox"])[1]',
         'value': ['USA (美国)']},
        # 分组
        {'selector': '(//section[@id="components-select-demo-optgroup"]//div[contains(@class,"ant-select ")])[1]',
         'value': ['yiminghe']},
    ]
    try:
        for selector in selectors:
            select = Select(browser, selector['selector'], Selector.XPATH)
            select.setValue(*selector['value'])
    finally:
        # pass
        browser.close()

